package com.example.xgakj.mvp_demo;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;

import com.socks.library.KLog;
import com.squareup.leakcanary.LeakCanary;

/**
 * Created by Administrator on 2017-07-12.
 */

public class App extends Application {
    private static Context appContext;

    @Override public void onCreate() {
        super.onCreate();
        KLog.init(BuildConfig.LOG_DEBUG);
        if (LeakCanary.isInAnalyzerProcess(this)) {
            return;
        }
        LeakCanary.install(this);
        appContext=this.getApplicationContext();
        registerCallBack();


    }

    private void registerCallBack() {
        registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
            @Override
            public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
                KLog.d("启动");
            }

            @Override
            public void onActivityStarted(Activity activity) {

            }

            @Override
            public void onActivityResumed(Activity activity) {

            }

            @Override
            public void onActivityPaused(Activity activity) {

            }

            @Override
            public void onActivityStopped(Activity activity) {

            }

            @Override
            public void onActivitySaveInstanceState(Activity activity, Bundle outState) {

            }

            @Override
            public void onActivityDestroyed(Activity activity) {

            }
        });
    }

    public static Context getAppContext() {
        return appContext;
    }
}
